﻿using Game;

namespace Program
{
    public class Program
    {
        public static void Main()
        {
            Game.ConsoleIO.ShowLogoScreen();
            Game.Engine.GameSettings newSetup = Game.ConsoleIO.GetSettingsFromUser();
            Game.Engine NewGame = new Game.Engine(newSetup);

            bool stayInProgram;
            do
            {
                stayInProgram = StartGame(NewGame);
                if (stayInProgram)
                {
                    ConsoleIO.GetDimensionsForSettings(ref newSetup); 
                    NewGame = new Game.Engine(newSetup);
                    NewGame.ResetPlayersScores(); 
                }
            } 
            while (stayInProgram == true);

            Ex02.ConsoleUtils.Screen.Clear();
            Game.ConsoleIO.ShowLogoScreen();
            System.Console.Write("Goodbye...\n");
            System.Console.ReadKey(true);
        }

        private static bool StartGame(Game.Engine i_Game)
        {
            bool anotherMatch = false;

            if (i_Game.Match() != Game.Engine.eInputType.Quit) 
            {
                anotherMatch = Game.ConsoleIO.AskForAnotherMatch(); 
            }

            return anotherMatch;
        }
    }
}
